#ifndef __CComponentFactory_H__
#define __CComponentFactory_H__

#include "compfwk/IComponentFactory.h"

namespace compfwk
{
    /**
     * \brief Template component factory
     *
     * Serves as component factory for any type of component
     * It's sole purpose it's to encapsulate the creation of
     * the components of a type.
     */
    template< typename TComponent >
    class CComponentFactory : public IComponentFactory
    {
    public:
        //! Default constructor
        CComponentFactory( );

        //! Destructor
        ~CComponentFactory( );

        //! Creates a component of the template type
        //! and returns it in a polymorphic way
        virtual TComponent* New( int a_eid ) const;

        //! Returns the TComponent type
        virtual CString GetType( void ) const;

        //! Returns the restrictions for TComponent
        virtual const CRstVector& GetRestrictions( void );

    private:
        //! Component of type TComponent that serves as prototype
        //! to get clones
        TComponent m_prototype;
    };

    template< typename TComponent >
    CComponentFactory::CComponentFactory( ) : m_prototype( )
    {
    }

    template< typename TComponent >
    CComponentFactory::~CComponentFactory( )
    {
    }

    template< typename TComponent >
    TComponent* CComponentFactory::New( int a_eid ) const
    {
        return m_prototype.Clone( a_eid );
    }

    template< typename TComponent >
    CString GetType( void ) const
    {
        TComponet comp;
        return comp.GetType( );
    }

    template< typename TComponent >
    const CRstVector& GetRestrictions( void )
    {
        // Not designed yet
        CRstVector aux;
        return aux;
    }
}
#endif